package com.qf.util;

/**
 * 天--道--酬--勤
 *
 * @author LiangGaoQiang
 * @ClassName R
 * @Date: 2025/4/3 20:37
 * @Description: 描述
 */

public class R {

    /**
     * code,指状态码,
     * 随意定,20000 是正确,40000 错误
     * 50000 请求超时
     * 60000 没有权限
     * 30000 是没有登录
     * msg,指信息描述
     * data,返回的数据
     */
    private int code;   // 状态码
    private String msg;  // 信息描述
    private Object data;  // 返回的数据

    public R() {
    }

    public R(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public static R ok() {
        R r = new R();
        r.setCode(20000);
        r.setMsg("成功");
        return r;
    }

    public static R ok(Object data) {
        R r = new R();
        r.setCode(20000);
        r.setMsg("成功");
        r.setData(data);
        return r;
    }


    public static R fail() {
        R r = new R();
        r.setCode(40000);
        r.setMsg("失败");
        return r;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
